function FilesLoader(files)
{
	if(files!=null)
	{
		this.files = files
	}
	this.callAtEnd = null
	this.callAtLoad = null
	this.objectsLoaded = 0;
	this.objectsToLoad = 0;

	this._objects = new Array();
	this._status = "init"
}
FilesLoader.prototype.load = function()
{
	this.status = "loading"

	var thisObject = this
	for(var i in this.files)
	{
		var file = this.files[i]
		switch(file[0])
		{
			case "js":
			var object = document.createElement('SCRIPT');
			this.objectsToLoad++;
			this._objects.push(object)
			object.onload = function()
			{
				thisObject.setFileLoaded(this)
			}
			object.onreadystatechange = function()
			{
				if(this.readyState=="complete" || this.readyState=="loaded")
				{
					thisObject.setFileLoaded(this)
				}
			}
			object.setAttribute('type', 'text/javascript');
			object.setAttribute('loading_src', file[1]);
			object.setAttribute('src', './js/'+file[1]+"?u="+file[2]);
			document.body.appendChild(object);
			break;
			case "css":
			var object = document.createElement('LINK');
			object.setAttribute('rel', 'stylesheet');
			object.setAttribute('type', 'text/css');
			object.setAttribute('href', './css/'+file[1]+"?u="+file[2]);
			document.body.appendChild(object);
			break;
		}
	}
	this.status = "wait"
	this.checkFileLoaded();
}
FilesLoader.prototype.setFileLoaded = function(elem)
{
	for(var i in this._objects)
	{
		if(this._objects[i]==elem)
		{
			this._objects[i] = null
			this.objectsLoaded++
			break;
		}
	}
	if(this.callAtLoad!=null)
	{
		this.callAtLoad(elem)
	}
	this.checkFileLoaded()
}
FilesLoader.prototype.checkFileLoaded = function()
{
	if(this.status != "wait") return;
	for(var i=0; i<this._objects.length; i++)
	{
		if(this._objects[i]!=null)
		{
			return;
		}
	}
	if(this.callAtEnd!=null)
	{
		this.callAtEnd()
	}
}


window.onload = function()
{
	document.onhelp = new Function("return false;"); // disable default help in IE
	
	document.onkeydown = function(event)
	{
		if(window.event)
		{
			event = window.event
		}
		if(event.keyCode==112)
		{
			alert("help");
			if(event.preventDefault)
			{
				event.preventDefault();
			}
			return false;
		}
	}
	
	
	ajax.sendAsync("./action/splash.php5?u="+new Date().getTime(), function(datas)
	{
		start_display_splash(datas)

		//on charge ensuite tous les autres scripts
		var fl = new FilesLoader(start_files)

		fl.callAtLoad = function(object)
		{
			document.getElementById("start_elem_loading").innerHTML = object.getAttribute("loading_src")
			document.getElementById("start_progressbar").style.width = fl.objectsLoaded*100/fl.objectsToLoad+"%"
		}

		fl.callAtEnd = function()
		{
			start_hide_splash("Loading")
			main_start()
		}

		fl.load()
	})
}

var start_popup = null
function start_display_splash(html)
{
	start_popup = new Popup(420, 220);
	start_popup.showModal(html)
}

function start_hide_splash()
{
	start_popup.hide()
	start_popup = null
}